/*
 * Stacker - [description needed]
 *
 * Copyright (c) 2013 Jude Osborn
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Version:  1.0.0
 *
 */

(function($, window, document, undefined) {
    
    var $window = $(window);

    $.fn.stacker = function(options) {
        
        var elements = this;
        var $container = this.parent();
        var settings = {
            threshold: 0,
            container: $container
        };

        function update() {

            var bottom = 0;

            elements.each(function() {
                
                var $this = $(this);
                var height = $this.outerHeight(true);
                $this.css({
                    "transform" : "translate3d(0px, -" + bottom + "px,0)"
                });

                bottom += height;
            });
        }

        if (options) {
            $.extend(settings, options);
        }

        $container = (settings.container === undefined ||
                      settings.container === window) ? $window : $(settings.container);

        this.each(function() {
            var self = this;
            var $self = $(self);
        });

        update();

        return this;
    };
})(jQuery, window, document);

var matrixToArray = function(str){
    return str.match(/\d+/g);
};